home *** CD-ROM | disk | FTP | other *** search
- /*
- File: AECdev.h
-
- Contains: AECDEV demonstrates the techniques needed to send AppleEvents
- from a CDEV/DA/INIT/Driver.
- Requires the sample AEDaemon to work.
-
- The techniques used in AECdev are the same you need to use to send AppleEvents
- from any non-application piece of code, DAs/INIT/Drivers, or anything else.
- Since the High Level Event manager will not let anyone post High Level Events
- unless they have an event loop, your non-event looped code must rely
- on a 'buddy' (in this case AEDaemon) to do the sending for you.
- There's not really much more code to write (just some PPC code), it's
- mainly a matter of moving the code from the CDEV to the backgrounder.
-
- Using a buddy and PPC can give you all the functionality of AppleEvents.
-
- Written by: C.K. Haun
-
- Copyright: Copyright © 1991-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/20/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <Devices.h>
- #include <Scrap.h>
- #include <menus.h>
- #include <PPCToolbox.h>
- #include <AppleEvents.h>
- #include <StandardFile.h>
- #include <EPPC.h>
- #include <Aliases.h>
- #include <events.h>
- #include <gestaltequ.h>
- #include <ToolUtils.h>
-
- /* Types */
- struct MyPPCRec {
- PPCParamBlockRec pB;
- Ptr buffer; /* buffer we're using */
- Size bufferSize; /* guess */
- Handle dataToXfer;
- PPCPortPtr myPort;
- PPCPortPtr buddyPortPtr;
- PPCPortRefNum ourPort;
- PPCSessRefNum currentSessionRef;
-
- };
- typedef struct MyPPCRec MyPPCRec, *MyPPCRecPtr,**MyPPCRecHandle;
-
-
- typedef struct CDEVRec {
- Handle spare;
- MyPPCRecPtr myPPCBlock;
- /* LocationName won't be needed, since we're staying local */
- Boolean searchForTarget; /* searchForTarget is our flag to tell us that we do not */
- /* know where AEBuddy is yet, and we have to keep looking. */
- /* It also implies (if true) that PBCat has already been */
- /* called, if necessary */
- Boolean noBuddy; /* PBCatSearch failed, give it up */
- Boolean notSys7;
- Boolean eventPending;
- } CDEVRec, *CDEVPtr, **CDEVHnd;
-
-
-
-
- struct MyPPCRecDeamon { /* to differenciact it from the one I'm using in teh CDEV */
- PPCParamBlockRec pB;
- Ptr buffer; /* buffer we're using */
- Size bufferSize; /* guess */
- Handle dataToXfer;
- PPCPortPtr myPort;
- PPCPortRefNum ourPort;
- PPCSessRefNum currentSessionRef;
-
- };
- typedef struct MyPPCRecDeamon MyPPCRecDeamon, *MyPPCRecPtrDeamon,**MyPPCRecHandleDeamon;
- #define kOneK 1024
- #define kMyTypeOfData 'MAVT'
- #define kGenericCreator '????'
- #define kSendButton 1
- #define kNoBuddyAlert -4048
- #define kNot70 -4049
- #define kStringsID -4048
- #define kBrowse1 1
- #define kBrowse2 2
- #define kMyName 3
- #define kWatchCursor 4
-
- pascal Handle AECDEV(short message, short item, short numItems, short CPanelID, EventRecord *theEvent, Handle cdevStorage,
- DialogPtr CPDialog);
- ControlHandle SnatchHandle(DialogPtr thebox, short theGetItem);
- void FindATarget(CDEVHnd storage);
- void FindAEBuddy(CDEVHnd storage);
- void FireTheEvent(Handle packedEvent, CDEVHnd storage);
- void OpenComplete(PPCStartPBPtr p);
- void StartComplete(PPCWritePBPtr p);
- void WriteComplete(PPCEndPBPtr p);
- void EndComplete(PPCClosePBPtr p);
-